# coding: utf8
from flask import render_template, request, url_for
from . import main_blueprint
from ..models.tables import Course
from ..models.schemas import CourseSchema
from .. import jd
from flask_uploads import send_from_directory


@main_blueprint.route('/')
def main_index():
    course = Course.query.all()
    print(jd.encode(course[0]))
    return render_template('index.html', title='welcome', ip=get_ip())


@main_blueprint.route('/test')
def main_test():
    return render_template('test.html')


@main_blueprint.route('/test1')
def main_test1():
    return render_template('test1.html')


@main_blueprint.route('/sI3fUs7Zoj.txt')
def text_index():
    import os
    return send_from_directory(os.getcwd(), 'sI3fUs7Zoj.txt')


def get_ip():
    return request.remote_addr
